package com.hongmeng.operater.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliyunConfigration {

    @Value("${aliyun.accessKey}")
    private String accessKey;
    @Value("${aliyun.accessSecret}")
    private String accessSecret;
    @Value("${aliyun.regionId}")
    private String regionId;

    /**
     * 手动注入 IAcsClient
     * @return
     */

    @Bean
    public IAcsClient initDefaultAcsClient()  {
        IClientProfile profile = DefaultProfile.getProfile(regionId, accessKey, accessSecret);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }
}
